﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace EmailMarketingCampaign
{
    public partial class MaintainRecord : System.Web.UI.Page
    {
        RecordControl rc = new RecordControl();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnGroup1_Click(object sender, EventArgs e)
        {


            if (txtGroup1.Text != "")
            {
                if (rc.checkRecordIn("group1", txtGroup1.Text.ToString(), Session["COMUniquelID"].ToString()))
                {
                    this.Response.Write(" <script>alert('there is existence record in Group1'); </script>");

                }
                else
                {

                    rc.InsertGroupRecord("group1", txtGroup1.Text.ToString(), Session["COMUniquelID"].ToString());

                    lbGroup1.DataBind();
                    txtGroup1.Text = "";

                }

            }
            else
            {
                this.Response.Write(" <script>alert('please enter frist'); </script>");


            }
        }

        protected void btnGroup2_Click(object sender, EventArgs e)
        {

            if (txtGroup2.Text != "")
            {
                if (rc.checkRecordIn("group2", txtGroup2.Text.ToString(), Session["COMUniquelID"].ToString()))
                {
                    this.Response.Write(" <script>alert('there is existence record in Group2'); </script>");

                }
                else
                {
                    rc.InsertGroupRecord("group2", txtGroup2.Text.ToString(), Session["COMUniquelID"].ToString());

                    lbGroup2.DataBind();
                    txtGroup2.Text = "";

                }

            }
            else
            {
                this.Response.Write(" <script>alert('please enter frist'); </script>");


            }
        }

        protected void btnGroup3_Click(object sender, EventArgs e)
        {

            if (txtGroup3.Text != "")
            {
                if (rc.checkRecordIn("group3", txtGroup3.Text.ToString(), Session["COMUniquelID"].ToString()))
                {
                    this.Response.Write(" <script>alert('there is existence record in Group3'); </script>");

                }
                else
                {
                    rc.InsertGroupRecord("group3", txtGroup3.Text.ToString(), Session["COMUniquelID"].ToString());

                    lbGroup3.DataBind();
                    txtGroup3.Text = "";

                }

            }
            else
            {
                this.Response.Write(" <script>alert('please enter frist'); </script>");


            }

        }

        protected void lbGroup1_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnGroup1.Enabled = false;
            btnGroup3.Enabled = false;
            btnGroup2.Enabled = false;
            btnEdit1.Enabled = true;
            txtGroup1.Text = lbGroup1.SelectedItem.Text;

        }

        protected void lbGroup2_SelectedIndexChanged(object sender, EventArgs e)
        {

            btnGroup1.Enabled = false;
            btnGroup3.Enabled = false;
            btnGroup2.Enabled = false;
            btnEdit2.Enabled = true;
            txtGroup2.Text = lbGroup2.SelectedItem.Text;
        }

        protected void lbGroup3_SelectedIndexChanged(object sender, EventArgs e)
        {

            btnGroup1.Enabled = false;
            btnGroup3.Enabled = false;
            btnGroup2.Enabled = false;
            btnEdit3.Enabled = true;
            txtGroup3.Text = lbGroup3.SelectedItem.Text;
        }
    }
}
